<template>
  <div> 
      <DetailBanner :sightName="sightName" :bannerImg="bannerImg" :gallaryImgs="gallaryImgs"></DetailBanner>
      <DetailHeader></DetailHeader>
      <div class="content">
        <DetailList :categoryList="categoryList"></DetailList>
      </div>
  </div>
</template>

<script>
import axios from 'axios'
import DetailBanner from './components/Banner.vue'
import DetailHeader from './components/Header.vue'
import DetailList from './components/List.vue'
export default {
  // 递归组件可以使用
  // keepalive过滤取消缓存
  name:'Detail',
  data() {
    return {
      sightName:'',
      bannerImg:'',
      gallaryImgs:[],
      categoryList:[],
    }
  },
  components:{
      DetailBanner:DetailBanner,
      DetailHeader:DetailHeader,
      DetailList:DetailList
  },
  methods:{
    getDeatilInFo(){
      // axios.get('/mock/detail.json?id=' + this.$route.params.id)
      axios.get('/mock/detail.json',{
        params:{
          id:this.$route.params.id
        }
      }).then(this.handleGetDataSucc)
    },
    handleGetDataSucc(res){
      // console.log('gao',res)
      res = res.data
      if(res.ret && res.data){
        const data = res.data
        console.log(data)
        this.sightName = data.sightName
        this.bannerImg = data.bannerImg
        this.gallaryImgs = data.gallaryImgs
        this.categoryList = data.categoryList
      }
    }
  },
  mounted(){
    this.getDeatilInFo()
  }
};
</script>

<style lang="stylus" scoped>
  .content
    height 50rem
</style>
